package com.briup.jz.web.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.AccountApply;
import com.briup.jz.bean.AccountApplyExample;
import com.briup.jz.bean.AccountCustomer;
import com.briup.jz.bean.AccountCustomerExample;
import com.briup.jz.bean.Category;
import com.briup.jz.service.IAccountApplyService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(description="账户变动")
@Validated
@RestController
@RequestMapping("/apply")
public class AccountApplyController {
	@Autowired
	private IAccountApplyService accountapplyservice;
	    @ApiOperation(value = "通过id删除账户变动")
	    @GetMapping("deleteById")
	    @ApiImplicitParams({
	        @ApiImplicitParam(name="id",value = "主键",paramType = "query", required=true),
	    })
	    public Message deleteById(Long id){
	    	System.out.println(id);
	        accountapplyservice.deleteByPrimaryKey(id);
	        return MessageUtil.success("删除成功");
	    }

	    @ApiOperation(value = "添加账户变动")
	    @ApiImplicitParams({
	    	    @ApiImplicitParam(name="id",value = "主键",paramType = "form"),
	            @ApiImplicitParam(name="money",value = "金额数",paramType = "form"),
	            @ApiImplicitParam(name="applyType",value = "提现方式",paramType = "form",required = true),
	            @ApiImplicitParam(name="applyTime",value = "提现时间",paramType = "form"),
	            @ApiImplicitParam(name="status",value = "状态",paramType = "form"),
	            @ApiImplicitParam(name="userId",value = "用户ID",paramType = "form"),
	            @ApiImplicitParam(name="reason",value = "原因",paramType = "form")
	    })
	    @PostMapping("insert")
	    public Message insert(AccountApply accountapply){
	        accountapplyservice.saveOrUpdate(accountapply);
	        return MessageUtil.success("更新成功");
	    }
	    @ApiOperation(value = "通过ID查询账户记录")
	    @GetMapping("selectById")
	    public AccountApply selectById(Long id){
	    	return accountapplyservice.selectByPrimaryKey(id);
	    }
	    @ApiOperation(value = "修改账户记录")
	    @GetMapping("updateById")
	    public Message updateByPrimaryKey(AccountApply record){
	    	accountapplyservice.saveOrUpdate(record);
	    	return MessageUtil.success("修改成功");
	    }
	    @ApiOperation(value = "查询账户记录")
	    @GetMapping("selectAll")
	    public Message selectByExample(AccountApplyExample example){
	    	List<AccountApply> list=accountapplyservice.selectByExample(example);
	    	return MessageUtil.success(list);
	    }
			
	    
	    }

